package com.jindu.producer.system.jpa;

import com.jindu.producer.system.model.SRoleMenuEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author jarvis
 * @date 2018-3-20
 */
@Transactional
public interface RoleMenuJpa extends JpaRepository<SRoleMenuEntity,Long>{

    SRoleMenuEntity findById(String id);

    /**
     * 根据角色的id，查询出menu的记录
     * @param roleId
     * @return
     */
    List<SRoleMenuEntity> findByRoleId(String roleId);


    @Modifying
    @Query("delete from SRoleMenuEntity where roleId = ?1 ")
    int deleteByRoleId(String roleId);


}
